import 'package:learning/bean/category_entity.dart';
import 'package:learning/generated/json/base/json_convert_content.dart';

CategoryEntity $CategoryEntityFromJson(Map<String, dynamic> json) {
  final CategoryEntity categoryEntity = CategoryEntity();
  final bool? enable = jsonConvert.convert<bool>(json['enable']);
  if (enable != null) {
    categoryEntity.enable = enable;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    categoryEntity.name = name;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    categoryEntity.content = content;
  }
  final String? icon = jsonConvert.convert<String>(json['icon']);
  if (icon != null) {
    categoryEntity.icon = icon;
  }
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    categoryEntity.id = id;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    categoryEntity.type = type;
  }
  return categoryEntity;
}

Map<String, dynamic> $CategoryEntityToJson(CategoryEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['enable'] = entity.enable;
  data['name'] = entity.name;
  data['content'] = entity.content;
  data['icon'] = entity.icon;
  data['id'] = entity.id;
  data['type'] = entity.type;
  return data;
}

extension CategoryEntityExtension on CategoryEntity {
  CategoryEntity copyWith({
    bool? enable,
    String? name,
    String? content,
    String? icon,
    int? id,
    int? type,
  }) {
    return CategoryEntity()
      ..enable = enable ?? this.enable
      ..name = name ?? this.name
      ..content = content ?? this.content
      ..icon = icon ?? this.icon
      ..id = id ?? this.id
      ..type = type ?? this.type;
  }
}